<?php
namespace App\Http\Controllers\Wap;

use App\Http\Controllers\Controller;
use App\Model\Core\Patient\PatientOrderModel;
use App\Model\Core\Sys\SysConfigModel;
use App\Service\Core\Patient\PatientOrderService;
use App\Service\Core\Sys\Config\SysConfigService;
use App\Service\ParamsService;
use Illuminate\Http\Request;

/**
 * h5协议
 * Class IndexController
 * @package App\Http\Controllers\Docker
 */
class IndexController extends Controller
{
    public function index(Request $request)
    {
        $config_item = trim($request->input('config_item'));
        if (empty($config_item)){
            dd('参数错误');
        }
        $SysConfigModel = SysConfigModel::getInstance();
        $config_info = $SysConfigModel->getConfig($config_item);
        if (!empty($config_info) && ParamsService::$config_item_list[$config_item]['type'] == 'fulltext'){
            if (!empty($config_info['config_val'])) {
                $config_info['config_val'] = convert_store_to_html($config_info['config_val']);
            }
        }
        return view('wap.index',compact('config_info'));
    }

    /**
     * 查看视频h5
     * @param Request $request
     */
    public function rtcView(Request $request)
    {
        $order = $request->get('order');
        $patient_sn = PatientOrderService::decryptOrderUrlParam($order);
        if (!$patient_sn) {
            return '参数错误';
        }
        $patient_order = PatientOrderService::getInstance()->getOne($patient_sn);
        $video_url = $patient_order['video_url'];
        if (empty($video_url)) {
            return '暂无视频';
        }
        return view('wap.rtc-view',compact('video_url'));
    }
}
